package com.example.chat.model;

import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import lombok.ToString;
import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;
import org.hibernate.annotations.GenericGenerator;

import javax.persistence.*;
import java.io.Serializable;

/**
 * @author ：YaXing
 * @description：职员角色中间表
 * @date ：2022/3/24 10:40
 */
@Entity
@Table(name = "VDOA009_EMPLOYEE_ROLE")
@Data
@ToString(callSuper = true)
@EqualsAndHashCode(callSuper = true)
@DynamicInsert
@DynamicUpdate
@NoArgsConstructor
public class EmployeeRole extends BaseEntity implements Serializable {

    private static final long serialVersionUID = -4571216540937340242L;
    @Id
    @GenericGenerator(name = "uuidG", strategy = "org.hibernate.id.UUIDGenerator")
    @GeneratedValue(generator = "uuidG")
    @Column(name = "DOA009_ID", length = 50)
    private String id;

    /**
     * 员工id
     */
    @Column(name = "DOA009_EMPLOYEE_ID", length = 50)
    private String employeeId;

    /**
     * 角色id
     */
    @Column(name = "DOA009_ROLE_ID", length = 50)
    private String roleId;

    @ManyToOne(targetEntity = Employee.class, fetch = FetchType.LAZY)
    @JoinColumn(name = "DOA009_EMPLOYEE_ID", updatable = false, insertable = false)
    private Employee employee;

    @ManyToOne(targetEntity = Role.class, fetch = FetchType.LAZY)
    @JoinColumn(name = "DOA009_ROLE_ID", updatable = false, insertable = false)
    private Role role;

    /**
     * 是否已删除
     */
    @Column(name = "DOA009_DELETED")
    private Boolean deleted = false;
}
